﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace GrayParrot.Web.Formly
{
    /// <summary>
    /// AddOn Position Enum...
    /// </summary>
    public enum Position
    {
        Left = 0,
        Right
    }

    /// <summary>
    /// 
    /// </summary>
    [AttributeUsage(AttributeTargets.Property, Inherited = false, AllowMultiple = true)]
    public class AddOnAttribute : Attribute
    {
        /// <summary>
        /// Gets or sets the text...
        /// </summary>
        /// <value>
        /// The text.
        /// </value>
        public string Text { get; set; }

        /// <summary>
        /// Gets or sets the class...
        /// </summary>
        /// <value>
        /// The class.
        /// </value>
        public string Class { get; set; }

        /// <summary>
        /// Gets or sets the on click funtion callback...
        /// </summary>
        /// <value>
        /// The on click.
        /// </value>
        /// <remarks>
        /// Will add a cursor:pointer and an ng-click to the addon (invoked with the options and scope)
        /// </remarks>
        public string OnClick { get; set; }

        /// <summary>
        /// Gets or sets the position.
        /// </summary>
        /// <value>
        /// The position.
        /// </value>
        public Position Position { get; set; }

        /// <summary>
        /// Gets or sets the callback that define a dynamic behavior for the AddOn GlyphIcon...
        /// </summary>
        /// <value>
        /// The dynamic behavior.
        /// </value>
        /// <remarks>
        /// The callback return a glyphicon based on external dynamic evaluations...
        /// </remarks>
        public string DynamicBehavior { get; set; }

        /// <summary>
        /// When implemented in a derived class, gets a unique identifier for this <see cref="T:System.Attribute" />.
        /// </summary>
        /// <remarks>
        /// This is a workaround for the Attributes marked as "Allow Multiple" and don't supported by the PropertyDescriptor.
        /// http://stackoverflow.com/questions/848669/allowmultiple-does-not-work-with-property-attributes
        /// </remarks>
        public override object TypeId
        {
            get
            {
                return this;
            }
        }

        /// <summary>
        /// Initializes a new instance of the <see cref="AddOnAttribute"/> class.
        /// </summary>
        public AddOnAttribute()
        {
            this.Text = string.Empty;
            this.Class = string.Empty;
            this.OnClick = string.Empty;
        }
    }
}
